//
//  AgreementViewController.m
//  Bullet
//
//  Created by  on 2019/8/29.
//  Copyright © 2019 . All rights reserved.
//

#import "AgreementViewController.h"
#import <WebKit/WebKit.h>
@interface AgreementViewController ()<WKNavigationDelegate>
{
    WKWebView * wevView;
//    view_back_NAview *view_backView;
}
@end

@implementation AgreementViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if (_Nav_title.length >0) {
//        [self addNavigationViewWithBoldTitle:_Nav_title];
    }
    NSURL *url = [NSURL URLWithString:_url];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [wevView loadRequest:request];
    [SVProgressHUDTool showWithStatus:nil];
}
-(void)showTextViewNavViewTo1{
    NSMutableArray * showTextViewNavViewNameArrTo1 = [NSMutableArray new];
    UIView * showTextViewNavViewViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewNavViewViewTo1.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:showTextViewNavViewViewTo1];
    UILabel * showTextViewNavViewLabelTo1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger showTextViewNavViewNumberTo1 = arc4random_uniform(20);
    NSLog(@"：%ld", (long)showTextViewNavViewNumberTo1);
    showTextViewNavViewLabelTo1.text = [NSString stringWithFormat:@"%ld",(long)showTextViewNavViewNumberTo1];
    [showTextViewNavViewLabelTo1 addSubview:showTextViewNavViewLabelTo1];
    
    UIImageView * showTextViewNavViewLabelTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [showTextViewNavViewViewTo1 addSubview:showTextViewNavViewLabelTo2];
    
}
- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = viewback_black;

    UIButton * backButton = [[UIButton alloc]initWithFrame:CGRectMake(11, 2+kStatusBarHeight, 40, 40)];
    [backButton setImage:KImageNamed(@"ico_nav_back_wite") forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backTap) forControlEvents:UIControlEventTouchUpInside];
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:backButton];
    
    UILabel * navLabel = [[UILabel alloc]initWithFrame:CGRectMake((KScreen_W-250)/2, 2+kStatusBarHeight, 250, 40)];
    navLabel.text = self.Nav_title;
    navLabel.font = FontMedium(18);
    navLabel.textColor = UIColor.whiteColor;
    navLabel.textAlignment = NSTextAlignmentCenter;
       UILabel * oldshowSSSSTip2 = [[UILabel alloc]init];
    oldshowSSSSTip2.clipsToBounds = YES;
    oldshowSSSSTip2.text = @"kass显示区";
    oldshowSSSSTip2.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip2.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip2.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip2.hidden = YES;
    [self.view addSubview:oldshowSSSSTip2];
    [self.view addSubview:navLabel];
//    view_backView = [[view_back_NAview alloc]initWithFrame:CGRectMake(0, 0, KScreen_W, kStatusBarHeight+44)];
       UILabel * oldshowSSSSTip5 = [[UILabel alloc]init];
    oldshowSSSSTip5.clipsToBounds = YES;
    oldshowSSSSTip5.text = @"kass显示区";
    oldshowSSSSTip5.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip5.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip5.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip5.hidden = YES;
    [self.view addSubview:oldshowSSSSTip5];
//    [self.view addSubview:view_backView];
//
//    [view_backView.view_backBtn addTarget:self action:@selector(view_backTap) forControlEvents:UIControlEventTouchUpInside];
    
    wevView = [[WKWebView alloc] init];
    //viewBackGroundColor;
    if (@available(iOS 11.0, *)) {
        wevView.frame = CGRectMake(0,KNav_H, KScreen_W, KScreen_H-KNav_H-KSafeAreaBottomHeight);
    } else {
        // Fallback on earlier versions
        wevView.frame = CGRectMake(0,KNav_H, KScreen_W, KScreen_H-KNav_H-KSafeAreaBottomHeight);
    }
    wevView.navigationDelegate = self;
    
    wevView.backgroundColor = viewback_black;
    wevView.opaque = NO;
       UILabel * oldshowSSSSTip23 = [[UILabel alloc]init];
    oldshowSSSSTip23.clipsToBounds = YES;
    oldshowSSSSTip23.text = @"kass显示区";
    oldshowSSSSTip23.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip23.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip23.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip23.hidden = YES;
    [self.view addSubview:oldshowSSSSTip23];
    [self.view addSubview:wevView];
}
- (void)backTap{
    if(self.isPerSent){
        [self dismissViewControllerAnimated:YES completion:nil];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}
#pragma mark - WKNavigationDelegate
// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    NSLog(@"加载完成");
    [SVProgressHUDTool dismiss];
}
//-(void)view_backTap{
//    [self dismissViewControllerAnimated:NO completion:nil];
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
